package com.yuke.cloud.service.cmc.controller.frontend;

import com.yuke.cloud.common.core.support.BaseController;
import com.yuke.cloud.common.util.wrapper.WrapMapper;
import com.yuke.cloud.common.util.wrapper.Wrapper;
import com.yuke.cloud.service.cmc.entity.CmsAppAd;
import com.yuke.cloud.service.cmc.service.CmsAppAdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
* Created by wg on 2019/01/18.
*/
@Api(value = "WEB - CmsAppAdController", tags = "处理CmsAppAd相关请求", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
@RequestMapping("/mall/cms/app_ad")
public class MallCmsAppAdController extends BaseController {
    @Resource
    private CmsAppAdService cmsAppAdService;

    @PostMapping("/app/condition")
    @ApiOperation(httpMethod = "POST", value = "app根据条件获取详情")
    public Wrapper<List<CmsAppAd>> getListDetailByCondition(@ApiParam(name = "cmsAppAd", value = "该数据记录的POJO") @RequestBody CmsAppAd cmsAppAd) {
        return WrapMapper.ok(cmsAppAdService.getListDetailByCondition(cmsAppAd));
    }

    @PostMapping("/app/adtag")
    @ApiOperation(httpMethod = "POST", value = "app根据条件获取详情")
    public Wrapper<CmsAppAd> getAdDetailById() {
        return WrapMapper.ok(cmsAppAdService.findById(20L));
    }

    /**
     * 推荐分类的图片
     * @return
     */
    @PostMapping("/app/adpos")
    @ApiOperation(httpMethod = "POST", value = "app根据条件获取详情")
    public Wrapper<CmsAppAd> getPost() {
        return WrapMapper.ok(cmsAppAdService.findById(21L));
    }


    /**
     * B 端轮播图的图片
     * @return
     */
    @GetMapping("/app/shouye")
    @ApiOperation(httpMethod = "POST", value = "app根据条件获取详情")
    public Wrapper<List<CmsAppAd>> getShouyePost() {
        List<CmsAppAd> cmsAppAdList = new ArrayList<>();
        cmsAppAdList.add(cmsAppAdService.findById(25L));
        cmsAppAdList.add(cmsAppAdService.findById(26L));
        cmsAppAdList.add(cmsAppAdService.findById(27L));
        return WrapMapper.ok(cmsAppAdList);
    }

}
